package com.tencent.bk.sdk.iam.constants;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import org.apache.commons.lang3.StringUtils;

public enum ActionTypeEnum {
    CREATE("create"),
    DELETE("delete"),
    VIEW("view"),
    EDIT("edit"),
    LIST("list"),
    UNDEFINED("");

    @JsonValue
    private String type;

    @JsonCreator
    public static ActionTypeEnum parseType(String type) {
        if (StringUtils.isBlank(type)) {
            return null;
        } else {
            for (ActionTypeEnum typeEnum:values()) {
                if (typeEnum.getType().equals(type)) {
                    return typeEnum;
                }
            }
            return null;
        }
    }

    public String getType() {
        return this.type;
    }

    private ActionTypeEnum(String type) {
        this.type = type;
    }
}
